package com.xiaobai.design_pattern.adapter;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author 王天文
 * @Date 2025/1/26 22:15
 * @Description:
 */
@Slf4j
public class FoodObjectAdapter implements Cook {

    private BaoZi baoZi;

    private ShuiJiao shuiJiao;

    private String name;

    public FoodObjectAdapter(String name) {
        this.name = name;
        if ("包子".equals(name)) {
            this.baoZi = new BaoZi();
        }
        if ("水饺".equals(name)) {
            this.shuiJiao = new ShuiJiao();
        }
    }

    @Override
    public void prepareMeal() {
        boolean flag = false;
        if ("包子".equals(name)) {
            flag = true;
            this.baoZi.makeBaoZi();
        }
        if ("水饺".equals(this.name)) {
            flag = true;
            this.shuiJiao.makeShuiJiao();
        }

        if (flag) {
            log.info("烹饪完成，食物是：{}", name);
        } else {
            log.error("无法烹饪！");
        }
    }
}
